package com.ad.pet.app.main.adapter;

import android.support.annotation.Nullable;
import android.widget.TextView;

import com.ad.pet.R;
import com.ad.pet.models.remote.main.PetConcer;
import com.ad.pet.utils.LyxUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by liuyixiang on 2019/11/20.
 */

public class PetConcerListAdapter extends BaseQuickAdapter<PetConcer,BaseViewHolder> {
    public PetConcerListAdapter( @Nullable List<PetConcer> data) {
        super(R.layout.item_pet_concer_list_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PetConcer item) {
    TextView tvTitle =  helper.getView(R.id.tv_title);
    TextView tvAddress = helper.getView(R.id.tv_address);
    TextView tvJUli = helper.getView(R.id.tv_juli);
    tvTitle.setText(item.getArea_name());
    tvAddress.setText(item.getPet_corner_address());
        double length = Double.valueOf(item.getDistance());
        String juli = "";
        if (length < 1000) {
            juli = length + "m";
        } else {
            juli = LyxUtils.formatDouble2(length / 1000) + "km";
        }
    tvJUli.setText(juli);
    }
}
